package com.ruoyi.web.controller.UserRealMoney;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.UserRealMoney.domain.UserRealmoney;
import com.ruoyi.UserRealMoney.service.IUserRealmoneyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 用户提现 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-07-31
 */
@Controller
@RequestMapping("/UserRealMoney/userRealmoney")
public class UserRealmoneyController extends BaseController
{
    private String prefix = "UserRealMoney/userRealmoney";
	
	@Autowired
	private IUserRealmoneyService userRealmoneyService;
	
	@RequiresPermissions("UserRealMoney:userRealmoney:view")
	@GetMapping()
	public String userRealmoney()
	{
	    return prefix + "/userRealmoney";
	}
	
	/**
	 * 查询用户提现列表
	 */
	@RequiresPermissions("UserRealMoney:userRealmoney:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(UserRealmoney userRealmoney)
	{
		userRealmoney.setValid(2);
		startPage();
        List<UserRealmoney> list = userRealmoneyService.selectUserRealmoneyList(userRealmoney);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出用户提现列表
	 */
	@RequiresPermissions("UserRealMoney:userRealmoney:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(UserRealmoney userRealmoney)
    {
    	List<UserRealmoney> list = userRealmoneyService.selectUserRealmoneyList(userRealmoney);
        ExcelUtil<UserRealmoney> util = new ExcelUtil<UserRealmoney>(UserRealmoney.class);
        return util.exportExcel(list, "userRealmoney");
    }
	
	/**
	 * 新增用户提现
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存用户提现
	 */
	@RequiresPermissions("UserRealMoney:userRealmoney:add")
	@Log(title = "用户提现", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(UserRealmoney userRealmoney)
	{		
		return toAjax(userRealmoneyService.insertUserRealmoney(userRealmoney));
	}

	/**
	 * 修改用户提现
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		UserRealmoney userRealmoney = userRealmoneyService.selectUserRealmoneyById(id);
		mmap.put("userRealmoney", userRealmoney);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存用户提现
	 */
	@RequiresPermissions("UserRealMoney:userRealmoney:edit")
	@Log(title = "用户提现", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(UserRealmoney userRealmoney)
	{		
		return toAjax(userRealmoneyService.updateUserRealmoney(userRealmoney));
	}
	
	/**
	 * 删除用户提现
	 */
	@RequiresPermissions("UserRealMoney:userRealmoney:remove")
	@Log(title = "用户提现", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(userRealmoneyService.deleteUserRealmoneyByIds(ids));
	}
	
}
